package indi.jp.project.business.yunying.controller;

import indi.jp.project.business.yunying.entity.MaterialFiled;
import indi.jp.project.core.entity.JsonResult;
import indi.jp.project.core.util.SimpleEntityUtil;
import indi.jp.project.business.yunying.service.MaterialFiledService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/yunying/material")
public class MaterialFiledController {

    @Resource
    private MaterialFiledService materialFiledService;

    @GetMapping("/queryGrid")
    public JsonResult queryGrid(MaterialFiled materialFiled, HttpServletRequest request) throws Exception {
        SimpleEntityUtil<MaterialFiled> entityUtil = new SimpleEntityUtil<>();
        entityUtil.setBaseEntity(materialFiled,request);
        return materialFiledService.queryGrid(materialFiled);
    }

    @PostMapping("/save")
    public JsonResult save(@RequestBody MaterialFiled materialFiled, HttpServletRequest request) throws Exception {
        SimpleEntityUtil<MaterialFiled> entityUtil = new SimpleEntityUtil<>();
        entityUtil.setBaseEntity(materialFiled,request);
        return materialFiledService.save(materialFiled);
    }

    @GetMapping("/findById")
    public JsonResult findById(@RequestParam String id) throws Exception {
        return materialFiledService.findById(id);
    }

    @PostMapping("/deleteById")
    public JsonResult deleteById(@RequestParam String id) throws Exception {
        return materialFiledService.deleteById(id);
    }

}
